﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmpAdd.aspx.cs" Inherits="FPC.Offer.UI.MangerEmp.MangerShow" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="..//favicon.ico">
    <link rel="Shortcut Icon" href="..//favicon.ico" />
    <link href="../H-ui/static/h-ui/css/H-ui.min.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/css/H-ui.admin.css" rel="stylesheet" />
    <link href="../H-ui/Lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/skin/default/skin.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/css/style.css" rel="stylesheet" />
    <link href="../H-ui/Lib/layer/2.4/skin/layer.css" rel="stylesheet" />
    <title>添加用户 - H-ui.admin v3.0</title>
        <!--_footer 作为公共模版分离出去-->
    <script src="../H-ui/Lib/jquery/1.9.1/jquery.min.js"></script>
    <script src="../H-ui/Lib/layer/2.4/layer.js"></script>
    <script src="../H-ui/static/h-ui/js/H-ui.js"></script>
    <script src="../H-ui/static/h-ui.admin/js/H-ui.admin.js"></script>
    <script src="../H-ui/Lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script src="../H-ui/Lib/laypage/1.2/laypage.js"></script>
    <script src="../H-ui/Lib/jquery/jquery-form.js"></script>
    <script>

        /*页面加载同时把下拉框的值附上*/
        $(function () {
            $.ajax({
                url: "../GeneralProcessor/MangerEmp/EmpManager.ashx",
                type: "post",
                data: {
                    Actioon: "<%=FPC.Offer.Common.EnumAction.Select %>",
                    name: "下拉"
                },
                success: function (n) {
                    var data = JSON.parse(n)
                    var role= [];
                    var Organize = [];
                    var dept = [];

                    //添加部门
                    $(data.lst1).each(function (i, item) {
                        dept.push("<option value=" + item.DeptId + " selected>" + item.OreganizeSublevelId + "</option>");
                    })
                    $("#dept").append(dept)
                    //部门默认显示第一条
                    var deptselected = document.getElementById("dept")
                    deptselected.selectedIndex = 0;
                    
                    //添加角色
                    $(data.lst2).each(function (i, item) {
                        role.push("<option value=" + item.RoleId + " selected>" + item.RoleName + "</option>");
                    })
                    $("#role").append(role)
                    //角色默认显示第一条
                    var roleselected = document.getElementById("role")
                    roleselected.selectedIndex = 0;

                    //添加公安局
                    $(data.lst3).each(function (i, item) {
                        Organize.push("<option value=" + item.OrganizeId + " selected>" + item.OrganizeName + "</option>");
                    })
                    $("#Organize").append(Organize)
                    //公安局默认显示第一条
                    var Organizeselected = document.getElementById("Organize")
                    Organizeselected.selectedIndex = 0;
                }
            })
        })
        /*添加数据*/
        function add() {
            var loginname = $("#loginname").val();
            var loginpwd = $("#loginpwd").val();
            var idcard = $("#idcard").val();
            var role = $("#role").val();
            var Organize = $("#Organize").val();
            var dept = $("#dept").val();

            var sex = parseInt($("input[name='sex']:checked").val());
            var name = $("#username").val();
            var tel = $("#mobile").val();
            var email = $("#email").val();
            var city = $("#select").val();
            var files = $("#file").val();

            var option = {
                url: "../GeneralProcessor/MangerEmp/EmpManager.ashx",
                type: "post",
                dataType: "json",
                data: {
                    Actioon: "<%=FPC.Offer.Common.EnumAction.Add %>",
                    getname: name,
                    Getsex: sex,
                    gettel: tel,
                    getemail: email,
                    getcity: city,
                    getloginname: loginname,
                    getloginpwd: loginpwd,
                    getidcard: idcard,
                    getrole: role,
                    getOrganize: Organize,
                    getdept: dept,
                    getfiles:files
                },
                success: function (n) {
                    if (n > 0) {
                       layer.alert('添加成功!');
                        layer_close();
                        location.href = "EmpManager.aspx";
                    }
                    else {
                        aler('添加失败!')
                    }
                }
            }
            //正则验证
            if (loginname == "")
            {
                layer.alert("登陆账户不能为空！")
            }
            if (loginpwd == "")
            {
                layer.alert("登陆密码户不能为空！");
            }
            var regpwd = /\w{8}/
            if (!regpwd.test(loginpwd)) {
                layer.alert("密码应该为8位字母或数字组成");
            }
            if (idcard == "")
            {
                layer.alert("身份证号不能为空！")
            }
            var regcard = /^\d{15}|\d{}18$ /;
            if (!regcard.test(idcard))
            {
                layer.alert("身份证号格式不对！");
            }
            if (name== "")
            {
                layer.alert("用户名不能为空！")
            }

            if (tel == "")
            {
                layer.alert("手机号不能为空！")
            };
            var regtel = /^\d{11}/;
            if (!regtel.test(tel))
            {
                layer.alert("手机号格式不正确")
            }
            if (email == "")
            {
                layer.alert("邮箱不能为空！")
            }
            var regemail = /^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/
            if (!regemail.test(email))
            {
                layer.alert("邮箱格式不正确")
            }
            if (files == "")
            {
                layer.alert("照片不能为空！");
            }
      
                $("#jvForm").ajaxSubmit(option)           
        }

    </script>
</head>
<body>
    <article class="page-container">
        <form  method="post" id="jvForm"  enctype="multipart/form-data" action="../GeneralProcessor/MangerEmp/EmpManager.ashx" id="form-member-add">
           <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账户：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="loginname" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="loginpwd" name="username">
            </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="username" name="username">
                </div>
            </div>
           <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">附件：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="btn-upload form-group">
                        <a href="../javascript:void();" class="btn btn-primary radius upload-btn" ><i class="Hui-iconfont">&#xe642;</i> 上传相片</a>
                        <input type="file" id="file" multiple name="file-2" class="input-file">
                    </span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>身份证号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="idcard" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input name="sex" type="radio" value="1" checked>
                        <label for="sex-1">男</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="sex-2" name="sex" value="2">
                        <label for="sex-2">女</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="sex-3" name="sex" value="3">
                        <label for="sex-3">保密</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="mobile" name="mobile">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="@" name="email" id="email">
                </div>
            </div>
             <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">角色：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="role" size="1" name="city">
                            <option value="0" selected>请分配角色</option>
                        </select>
                    </span>
                </div>
               </div>
             <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在派出所：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="Organize" size="1" name="city">
                            <option value="0" selected>请选择派出所</option>
                        </select>
                    </span>
                </div>
             <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在部门：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="dept" size="1" name="city">
                            <option value="0" selected>请选择部门</option>
                        </select>
                    </span>
                </div>
            </div>

            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在城市：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="select" size="1" name="city">
                            <option value="" selected>请选择城市</option>
                            <option value="北京">北京</option>
                            <option value="上海">上海</option>
                            <option value="广州">广州</option>
                        </select>
                    </span>
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="button" id="bt1" onclick="add()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>

</body>
</html>
